<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class loan_customer extends Model
{
    protected $table = 'customer';

    protected $primaryKey = 'id';

    protected $fillable = [
        'money_type', 'name', 'Id_per' , 'email','tel','addr','money','data_type','img', 'status','state','limits','repayment'
    ];

    protected $appends = [
        'status_desc',
        'state_desc',
    ];

    public function record()
    {
        return $this->hasMany(Record::class, 'pid', 'id');
    }

    public function getStatusDescAttribute($value)
    {
        switch ($this->attributes['status']) {
            case '1':
                $name = '审核通过';
                break;
            case '2':
                $name = '审核不通过';
                break;
            default:
                $name = '未审核';
                break;
        }

        return $name;
    }
    public function getStateDescAttribute($value)
    {
        switch ($this->attributes['state']) {
            case '0':
                $name = '正常';
                break;
            case '1':
                $name = '不正常';
                break;
            case '2':
                $name='还款已完成';
                break;
        }

        return $name;
    }
}
